package com.springTxStudy.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class StudentDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;


    public boolean updateNameById(int id, String name) {
        String sql = "update students set name=? where id=?";
        int row = jdbcTemplate.update(sql, name, id);
        return row > 0;
    }

    public boolean updateAgeById(int id, int age) {
        String sql = "update students set age=? where id=?";
        int row = jdbcTemplate.update(sql, age, id);
        return row > 0;
    }
}
